GitHub Actionsでblackで整形したコミット 実装例
psf/black@stableではコミットまではされない
ref: Black document: GitHub Actions integration
1つ目のjob
まずpsf/black@stableで--check --diff --line-length 79
2つ目のjob: 1つ目の終了コードが0以外(=整形の必要性あり)のとき
整形 --line-length 79
コミットを作る
コミットを作るアクション git-auto-commit-action
前のstepが失敗していたらこのstepを実行するというfailureは今回は使いどころではなさそう
https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#example-using-status-check-functions
依存関係にあるjobが失敗していたら実行すると実装
例:https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2
if: failure()でスッキリ書けたというコメントあり
jobs.<job_id>.needs
https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idneeds
jobs.<job_id>.if
https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idif